package com.rede.didiok.rank.restapi;

import javax.annotation.Resource;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.rede.didiok.common.constant.conf.SysConf;
import com.rede.didiok.common.dto.rank.RankMemberDto;
import com.rede.didiok.common.enums.AuditStatusEnum;
import com.rede.didiok.common.enums.PublishEnum;
import com.rede.didiok.common.exception.ThrowableUtils;
import com.rede.didiok.common.feign.AdminFeignClient;
import com.rede.didiok.common.feign.CommunityFeignClient;
import com.rede.didiok.common.feign.UserFeignClient;
import com.rede.didiok.common.utils.RedisUtil;
import com.rede.didiok.common.utils.ResultUtil;
import com.rede.didiok.common.validator.group.GetList;
import com.rede.didiok.rank.service.RankMemberService;

/**
 * 关于我 RestApi
 *
 * @author 陌溪
 * @date 2018年11月12日14:51:54
 */
@RestController
@RequestMapping("/about/user")
@Api(value = "关于我相关接口", tags = {"关于我相关接口"})
@Slf4j
public class UserCenterRestApi {

    @Resource
    private AdminFeignClient adminFeignClient;
    @Resource
    private RankMemberService rankMemberService;
    @Resource
    private UserFeignClient userFeignClient;
    @Resource
    private CommunityFeignClient communityFeignClient;
    @Autowired
    private RedisUtil redisUtil;

    @ApiOperation(value = "通过用户获取榜单成员列表", notes = "通过用户获取榜单成员列表")
//    @PostMapping("/getBlogListByUser")
    @PostMapping("/getRankMemberListByUser")
    public String getRankMemberListByUser(@Validated({GetList.class}) @RequestBody RankMemberDto rankMemberDto, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("通过用户获取博客列表");
        rankMemberDto.setIsPublish(PublishEnum.PUBLISH);
        rankMemberDto.setAuditStatus(AuditStatusEnum.AGREE);
        return ResultUtil.result(SysConf.SUCCESS, rankMemberService.getPageListWithPicAndRank(rankMemberDto));
    }

}

